package br.com.eduquiz.session;

import br.com.eduquiz.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.framework.EntityHome;

@Name("telefoneHome")
@Restrict("#{s:hasRole('AdministradorGrupo')}")
public class TelefoneHome extends EntityHome<Telefone> {

	private static final long serialVersionUID = -7354208531016162266L;

	@In(create = true)
	private AdministradorGrupoHome administradorGrupoHome;

	public void setTelefoneId(Long id) {
		setId(id);
	}

	public Long getTelefoneId() {
		return (Long) getId();
	}

	@Override
	protected Telefone createInstance() {
		Telefone telefone = new Telefone();
		return telefone;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		AdministradorGrupo administradorGrupo = administradorGrupoHome
				.getDefinedInstance();
		if (administradorGrupo != null) {
			getInstance().setAdministradorGrupo(administradorGrupo);
		}
	}

	public boolean isWired() {
		return true;
	}

	public Telefone getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
